<?php
/**
 * Create by Phpstorm
 * User: Peco
 * Date: 2019/12/17
 * Time: 18:00
 */

namespace App\Http\Controllers\Api\Shop;

use App\Http\Controllers\Api\BaseAdminController;
use App\Http\Requests\Pay\UserAmountPageRequest;
use App\Http\Requests\Pay\UserIntegralPageRequest;
use App\Http\Requests\Pay\UserWithdrawPageRequest;
use App\Http\Transformers\Pay\UserAmountTransformer;
use App\Http\Transformers\Pay\UserIntegralTransformer;
use App\Http\Transformers\Pay\UserWithdrawTransformer;
use App\Repositories\PayRepository;

/**
 * Class PayController
 * @package App\Http\Controllers\Api\Mall
 */
class PayController extends BaseAdminController
{
    /**
     * @var PayRepository 注入的数据模型
     */
    protected $payRepository;

    /**
     * PayController constructor.
     * @param PayRepository $payRepository
     */
    public function __construct(PayRepository $payRepository)
    {
        $this->payRepository = $payRepository;
    }

    /**
     * 用户资金消费明细列表
     * @param UserAmountPageRequest $request
     * @return \Dingo\Api\Http\Response
     */
    public function userAmountPage(UserAmountPageRequest $request){
        $limit = $request->get('limit', LIMIT_PAGE);
        $data = $request->all(['phone']);

        $list = $this->payRepository->userAmountPageRepository($limit, $data);

        return $this->response->paginator($list, new UserAmountTransformer());
    }

    /**
     * 用户积分明细列表
     * @param UserIntegralPageRequest $request
     * @return \Dingo\Api\Http\Response
     */
    public function userIntegralPage(UserIntegralPageRequest $request){
        $limit = $request->get('limit', LIMIT_PAGE);
        $data = $request->all(['phone']);

        $list = $this->payRepository->userIntegralPageRepository($limit, $data);

        return $this->response->paginator($list, new UserIntegralTransformer());
    }

    /**
     * 用户提现明细列表
     * @param UserWithdrawPageRequest $request
     * @return \Dingo\Api\Http\Response
     */
    public function userWithdrawPage(UserWithdrawPageRequest $request){
        $limit = $request->get('limit', LIMIT_PAGE);
        $data = $request->except(['limit', 'page']);

        $list = $this->payRepository->userWithdrawPageRepository($limit, $data);

        return $this->response->paginator($list, new UserWithdrawTransformer());
    }
}
